# Reference on this file: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# To make it work, go to the repository settings, then Options, GitHub Pages and select `gh-pages` under Source.
name: Publish the demo
on:
  push:
    branches:
      - master
jobs:
  publish:
    name: Publish the demo
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Cache
        uses: actions/cache@v3
        with:
          path: node_modules
          key: nodemodules-${{ hashFiles('yarn.lock') }}
          restore-keys: nodemodules-
      - name: Install Node packages
        run: yarn install
      - name: Build the demo
        run: yarn playground:build
      - name: Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          branch: gh-pages
          folder: playground/dist
          clean: true
          single-commit: true
      - name: Print the demo URL
        run: echo "✅ The demo has been deployed to https://$(cut -d'/' -f1 <<< $GITHUB_REPOSITORY).github.io/$(cut -d'/' -f2 <<< $GITHUB_REPOSITORY)/"
